Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

feat(dbt-fal): add fal cloud context #788

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mederka
Copy link
Collaborator

@mederka mederka commented Mar 14, 2023

Provides new cloud context, with store_open method that works like open but in cloud context.

def model(dbt, fal):
    from utils.get_bool import get_bool
    with fal.store_open("test", "w") as f:
        f.write("hello world")

    df = dbt.ref("model_b")

    df["my_bool"] = get_bool()
    return df

@mederka mederka requested a review from a team March 14, 2023 16:31
@mederka mederka marked this pull request as ready for review March 14, 2023 16:31
Copy link
Member

@chamini2 chamini2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated question:

def model(dbt, fal):
    from utils.get_bool import get_bool
    with fal.store_open("test", "w") as f:
        f.write("hello world")

    df = dbt.ref("model_b")

    df["my_bool"] = get_bool()
    return df

the from utils.get_bool import get_bool already works in the cloud, right?

@@ -37,6 +38,7 @@ def run_with_adapter(code: str, adapter: BaseAdapter, config: RuntimeConfig) ->
return main(
read_df=prepare_for_adapter(adapter, read_relation_as_df),
write_df=prepare_for_adapter(adapter, write_df_to_relation),
fal_context=FalCloudContext() if is_cloud else None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say the context should always be there, not just for cloud.

class FalContext:
  ...

class FalCloudContext(FalContext):
  ... # implement the differences

class FalLocalContext(FalContext):
  ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We always thought of these things working the same locally and in the cloud.

self.options = options

def __enter__(self):
self.file = open(self.path, self.options)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ATL: is this opening in the /data dir or a temp one in the cloud?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants